package com.yy.kit.zfb;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayOpenPublicMenuCreateRequest;
import com.alipay.api.response.AlipayOpenPublicMenuCreateResponse;

import com.yy.kit.zfb.factory.AlipayAPIClientFactory;

/**
 * <p>
 * 支付宝生活号菜单的工具类
 * </p>
 * @author 杨阳
 * @since 2017年9月30日
 */
public class YYZFBMenuKits {
	
	// 创建服务窗菜单信息
		public static void createMenu() {
			AlipayClient alipayClient = AlipayAPIClientFactory.getAlipayClient();
			AlipayOpenPublicMenuCreateRequest request = new AlipayOpenPublicMenuCreateRequest();
			Map<String, Object> menuMap = new HashMap<String, Object>();
			List<Map<String, Object>> buttonList = new ArrayList<Map<String, Object>>();
			Map<String, Object> map1 = new HashMap<String, Object>();
			map1.put("name", "测试");
			map1.put("action_type", "link");
			map1.put("action_param", "www.baidu.com");
			buttonList.add(map1);
			menuMap.put("button", buttonList);
			request.setBizContent(JSONObject.toJSONString(menuMap));
			System.err.println(JSONObject.toJSONString(menuMap));
			AlipayOpenPublicMenuCreateResponse response = null;
			try {
				 response = alipayClient.execute(request);
				 System.out.println(response.getBody());
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
	
	
}
